package com.swy.shopgroup.adapter;


import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainViewPagerAdapter extends FragmentPagerAdapter {

    private List<Fragment> list;

    public MainViewPagerAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm,BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.list = new ArrayList<>();
        this.list.clear();
        this.list.addAll(list);
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }


    @Override
    public int getCount() {
        return list.size();
    }

    public Fragment getFragment(int position) {
        if (list != null) {
            return list.get(position);
        }
        return null;
    }
}
